#!/usr/bin/env bash


# https://mariadb.com/resources/blog/getting-started-with-mariadb-galera-and-mariadb-maxscale-on-centos/

docker network create -d bridge  --subnet=172.72.0.0/16 mynet
docker build -t mariadb -f ./mariadb.Dockerfile .
docker build -t galera -f ./galera.Dockerfile .
docker build -t maxscale -f ./maxscale.Dockerfile .

docker run --privileged=true  -u root  --net mynet -itd --ip 172.72.0.11 -p 3401:3306  --name node1 galera /usr/sbin/init
docker run --privileged=true  -u root  --net mynet -itd --ip 172.72.0.12 -p 3402:3306  --name node2 galera /usr/sbin/init
docker run --privileged=true  -u root  --net mynet -itd --ip 172.72.0.13 -p 3403:3306  --name node3 galera /usr/sbin/init


docker run --privileged=true  -u root  -p 3306:3306  --name maxscale --net mynet -itd --ip 172.72.0.36 maxscale